<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="./jquery.min.js"></script>
    <link rel="stylesheet" href="./vant/index.css">
    <!-- 引入 Vue 和 Vant 的 JS 文件 -->
    <script src="./vant/vue.js"></script>
    <script src="./vant/index.js"></script>
    <title>制定计划</title>
</head>

<body>
    <script>
        var cardId = localStorage.getItem("cardId");
        var cardDetialJson = JSON.parse(localStorage.getItem("commitPlan"));
        var cardDetial, signorderNo = localStorage.getItem("signorderNo");
        $.ajax({
            url: 'https://community.1818pay.cn/customer/bankCard/findCardById',
            type: 'get',
            dataType: 'json',
            data: {
                id: cardId,
                // id:'2387'
            },
            success: function (data) {
                console.log(data)
                if (data.code == 1000) {
                    cardDetial = data.data;
                    $.ajax({
                        url: 'https://community.1818pay.cn/plan/plan/sign',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            cardId: cardDetial.id, //卡id
                            creditCardCode: cardDetial.bankCode, //银行编号
                            year: '29', //有效年
                            month: '12', //有效月
                            smsCode: 'noCode', //短信验证码vv
                            cv2: '123', //cv2
                            orderNo: signorderNo, //随机订单号，后台生成
                            aisleCode: cardDetialJson.aisle, //通道标识
                            aisleMerId: cardDetialJson.aisleMerId, //通道商户号
                            creditCardPhone: cardDetial.reservePhone, //开户手机号
                            customerId: cardDetial.customerId, //customerId
                            creditCardNo: cardDetial.bankCard //开户卡号
                        },
                        success: function (data) {
                            if (data.code == 1000) {
                                vant.Dialog.alert({
                                    title: '提示',
                                    message: '计划创建成功！'
                                }).then(() => {
                                    // window.location = 'https://community.1818pay.cn:1181/plan?token=123'
                                    window.location = 'https://community.1818pay.cn:1181/plan/#/dzx?'+Math.random();
                                });
                            } else {
                                vant.Toast.loading(data.message)
                            }
                        },
                        error: function (XMLHttpRequest) {
                            switch (XMLHttpRequest.status) {
                                case 400:
                                    errorMsg = "问题原因:传递参数出现问题"
                                    break;
                                case 403:
                                    errorMsg = "问题原因:访问协议出现问题"
                                    break;
                                case 404:
                                    errorMsg = "问题原因:服务端重新启动中或者接口路径错误"
                                    break;
                                case 405:
                                    errorMsg = "问题原因:请求方式存在问题"
                                    break;
                                case 500:
                                    errorMsg = "问题原因:服务端异常"
                                    break;
                            }
                            vant.Toast.loading(errorMsg)
                        }
                    })
                } else {
                    vant.Toast.loading(data.message)
                }
            },
            error: function (XMLHttpRequest) {
                switch (XMLHttpRequest.status) {
                    case 400:
                        errorMsg = "问题原因:传递参数出现问题"
                        break;
                    case 403:
                        errorMsg = "问题原因:访问协议出现问题"
                        break;
                    case 404:
                        errorMsg = "问题原因:服务端重新启动中或者接口路径错误"
                        break;
                    case 405:
                        errorMsg = "问题原因:请求方式存在问题"
                        break;
                    case 500:
                        errorMsg = "问题原因:服务端异常"
                        break;
                }
                vant.Toast.loading(errorMsg)
            }
        })
    </script>
</body>

</html>